package com.lh.controller;


import com.lh.commonutils.R;
import com.lh.entity.subject.OneSubject;
import com.lh.service.IEduSubjectService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 课程科目 前端控制器
 * </p>
 *
 * @author yms
 * @since 2021-06-04
 */
@RestController
@RequestMapping("subject")
//@CrossOrigin
@Api(value = "课程分类管理接口")
public class EduSubjectController {

    @Resource
    private IEduSubjectService eduSubjectService;

    @ApiOperation(value = "添加课程类别")
    @PostMapping("addSubject")
    public R addSubject(MultipartFile file){
        System.out.println("dfdsfassfdsafsedf");
        eduSubjectService.saveSubject(file,eduSubjectService);
        return R.ok();
    }

    @ApiOperation(value = "课程分类列表")
    @GetMapping("getAllSubject")
    public R getAllSubject(){

        List<OneSubject> list = eduSubjectService.getAllSubject();
        System.out.println(list);
        return R.ok().data("list",list);
    }

}
